﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using WCYCReader.ViewModels;
using WCYCReader.Main;

namespace WCYCReader.Pages
{
    public partial class BookTypePage : PhoneApplicationPage
    {
        private OriginalCategoryList_VM ocl_vm = new OriginalCategoryList_VM();

        private PublishingCategoryList_VM pcl_vm = new PublishingCategoryList_VM();

        public BookTypePage()
        {
            this.InitializeComponent();
        }

        private void ContentGrid_Loaded(object sender, RoutedEventArgs e)
        {
            App.QQReader_prePageId = App.QQReader_pageId;
            App.QQReader_pageId = "QQReader_CategoryPage";
        }

        private void ContentGrid_Unloaded(object sender, RoutedEventArgs e)
        {
        }

        

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void originalCategoryListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox listBox = sender as ListBox;
            if (listBox.SelectedIndex >= 0)
            {
                string str = string.Concat("?Category=", this.ocl_vm.T_OriginalCategoryList_VM[listBox.SelectedIndex].str_CategoryId_M, "&CategoryName=", this.ocl_vm.T_OriginalCategoryList_VM[listBox.SelectedIndex].str_CategoryName_M);
                NaviService.Navigate(QQReaderPage.EBookCityListPage, str);
            }
            listBox.SelectedIndex = -1;
        }

        private void publishingCategoryListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox listBox = sender as ListBox;
            if (listBox.SelectedIndex >= 0)
            {
                string str = string.Concat("?Category=", this.pcl_vm.T_PublishingCategoryList_VM[listBox.SelectedIndex].str_CategoryId_M, "&CategoryName=", this.pcl_vm.T_PublishingCategoryList_VM[listBox.SelectedIndex].str_CategoryName_M);
                NaviService.Navigate(QQReaderPage.EBookCityListPage, str);
            }
            listBox.SelectedIndex = -1;
        }
    }
}